<template>
  <a-drawer width="850" :title="formTitle" :label-col="4" :wrapper-col="14" :visible="open" :body-style="{ height: 'calc(100vh - 100px)', overflow: 'auto' }" @close="cancel">
    <a-form-model ref="form" :model="form" :rules="rules" layout="vertical">
      <a-spin :spinning="spinning" :delay="delayTime" tip="Loading...">
        <a-row :gutter="32">
          <a-col :span="8" v-if="chooseUserDisabled">
            <a-form-model-item label="用户" prop="userId">
              <select-user v-model="form.userId" select-model="single" placeholder="请选择用户" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="版块" prop="sectionId">
              <select-section v-model="form.sectionId" placeholder="请选择版块" status="2" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="帖子类型" prop="type">
              <a-select
                placeholder="请选择类型"
                v-model="form.type"
                :getPopupContainer="
                  triggerNode => {
                    return triggerNode.parentNode || document.body
                  }
                "
                style="width: 100%"
                allow-clear
              >
                <a-select-option v-for="(d, index) in typeOptions" :key="index" :value="d.dictValue">{{ d.dictLabel }}</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="4">
            <a-form-model-item label="联系人" prop="contact">
              <a-input v-model="form.contact" placeholder="请输入联系人" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="联系电话" prop="phone">
              <a-input v-model="form.phone" placeholder="请输入联系电话" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="地址" prop="address">
              <a-input v-model="form.address" placeholder="请输入地址" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="是否匿名" prop="anonymity">
              <a-radio-group v-model="form.anonymity" :defaultValue="form.status">
                <a-radio v-for="(dict, index) in anonymityOptions" :key="index" :value="dict.dictValue">
                  {{ dict.dictLabel }}
                </a-radio>
              </a-radio-group>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="帖子标题" prop="title">
              <a-input v-model="form.title" placeholder="请输入帖子标题" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="帖子内容" prop="content" class="addModel">
              <editor ref="editor" v-model="form.content" ></editor>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="帖子封面" prop="image">
              <image-upload v-model="form.image" isMultiple :number="1" />
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="24">
            <a-form-model-item label="帖子发布时间" prop="publishTime">
              <a-date-picker
                v-model="form.publishTime"
                :default-value="form.publishTime ? moment(form.publishTime, dateFormat) : null"
                :disabledDate="disabledDatePublish"
                :disabledTime="disabledTimePublish"
                :valueFormat="dateFormat"
                :show-today="true"
                show-time
                placeholder="选择日期"
                style="width: 100%"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="帖子修改时间" prop="editTime">
              <a-date-picker v-model="form.editTime" :default-value="form.editTime ? moment(form.editTime, dateFormat) : null" :disabledDate="disabledDateEdit" :disabledTime="disabledTimeEdit" :valueFormat="dateFormat" :show-today="true" show-time placeholder="选择日期" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="帖子点赞数" prop="likeNumber">
              <a-input-number v-model="form.likeNumber" :min="0" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="帖子收藏数" prop="collectNumber">
              <a-input-number v-model="form.collectNumber" :min="0" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="帖子回复数" prop="replyNumber">
              <a-input-number v-model="form.replyNumber" :min="0" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="帖子浏览数" prop="viewNumber">
              <a-input-number v-model="form.viewNumber" :min="0" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="帖子举报数" prop="reportNumber">
              <a-input-number v-model="form.reportNumber" :min="0" style="width: 100%" />
            </a-form-model-item>
          </a-col> -->
        </a-row>
      </a-spin>
      <div class="bottom-control">
        <a-space>
          <a-button :disabled="disabled" @click="cancel"> 取消 </a-button>
          <a-button type="primary" :disabled="disabled" @click="submitForm(true)"> 保存 </a-button>
        </a-space>
      </div>
    </a-form-model>
  </a-drawer>
</template>
<script>
import PostEditForm from './PostForm'
export default {
  ...PostEditForm
}
</script>
<style lang="less">
.addModel {
  .vditor-toolbar--pin {
    top: auto !important;
  }
}
</style>
